Part Number Hot Search : 
U10A6CIC KBL00 SH90207 PMEG20 SBT3040 HIP6301 MV5B60 CD2087
Product Description
Full Text Search
 

To Download AN1447 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  AN1447/0901 1/26 AN1447 application note software driver for 4-multiplexed lcd with a standard st62 by microcontroller division applications description this note describes a technique for driving a 4-multiplexed liquid crystal display (lcd) with a standard st62 microcontroller (mcu), without any dedicated lcd driver peripheral. this technique offers a display capability for applications which require a small display at a low cost together with the versatile capabilities of the standard st62xx mcu. higher display requirements are easily handled by dedicated members of the st62 mcu family, for example the st6240. solutions on how to use a standard st6 to drive an lcd with a multiplexing ratio of 2 (duplex) can be found in application note an594. the first section of this note describes the typical waveforms required to drive an lcd, first without multiplexing (direct drive), then with a multiplexing rate of 4. the second section ex- plains how to use a software library written in assembly language (mast6 syntax) imple- menting a solution based on a standard st62 mcu driving directly the lcd. the program size and the cpu time occupation due to the lcd drive are minimized. conse- quently many additional tasks can be added to the mcu program. only few cheap additional components are required. 1
2/26 4-multiplexed lcd with a standard st62 1 lcd driving principles 1.1 lcd requirements an lcd segment can either be transparent (off) or opaque (on), depending on the voltage applied to it. on figure 1, this voltage is the difference between com and s voltages. on most lcds (reflective positive displays) an opaque segment is seen dark and a transparent seg- ment is seen clear (same colour as the background). figure 1. equivalent electrical schematic of an lcd segment if no voltage is applied to it, a segment is transparent. to make it opaque, the lcd driver must apply an ac voltage which root mean square (rms) value is above a certain threshold. this voltage threshold depends on the lcd characteristics. segment voltage must also comply with the following conditions: C its absolute dc (mean) value must be very low (under 100 mv typically). otherwise, the life time of the lcd can be shortened. C its frequency must be in the range 30 C 2000 hz typically. if too low, the display flickers. if too high, driving generates more power consumption. 1.2 direct lcd drive each lcd segment is located between a segment electrode and a backplane common to all the segments (see figure 2). therefore, a display using n segments contains ( n +1) external connections: n segment electrode pins (s 0 , s 1 ,) and 1 common pin (com). c r s s com segment electrode backplane 2
3/26 4-multiplexed lcd with a standard st62 figure 2. connections inside a direct drive lcd all these pins are connected to mcu i/o pins operating in output mode, either at logic level 0 or at logic level 1. the backplane is driven with a signal com controlled between 0 and v dd with a duty cycle of 50%. when selecting a segment on, a signal with opposite polarity to com is sent to the corre- sponding segment electrode pin. when the non-inverted signal com is sent to the segment electrode pin, the segment is off. figure 3. lcd signals for non-multiplexed drive note: on figure 3, s signal is the segment electrode voltage and s d the segment voltage. s 1 com backplane s 0 segment electrodes t t t com s s d = com - s v d d 0 v d d 0 v d d 0 -v d d ( s d ) rms = 0 t segment off ( s d ) rms = v dd t segment on s d
4/26 4-multiplexed lcd with a standard st62 1.3 4-multiplexed lcd drive for 4-multiplexed drive, four backplanes are used instead of one. the lcd segments are equally distributed between the four backplanes. they form groups of 4 segments, where each segment is allocated to a different backplane. all the segment electrodes (or frontplane electrodes) belonging to the same group are connected to a single external pin. thus, a dis- play using n segments contains ( n /4+4) external connections: n/4 pins driving groups of seg- ment electrodes (s 0 , s 1 ,) and 4 common pins (com 0 , com 1 , com 2 and com 3 ). on the rest of this document, the pins driving groups of segment electrodes are called frontplane pins. figure 4. connections inside a 4-multiplexed lcd three different voltage levels have to be generated on the backplanes: 0, v dd /2 and v dd . the frontplane voltage levels are 0 and v dd only. figure 5 shows typical backplane, frontplane and segment voltage waveforms. each period is divided into 8 phases j 0 to j 7 . like in direct drive, com waveforms are applied continuously, whereas s waveforms depend on the required display. the logic level applied on s during phase j 4 is the negation of the one applied during phase j 0 , and so on for j 5 and s 1 com 3 backplanes s 0 segment electrodes com 2 com 1 com 0 pins driving groups of segment electrodes
5/26 4-multiplexed lcd with a standard st62 j 1 , j 6 and j 5 , j 7 and j 3 . changing the levels applied during phases j 0 and j 4 does not change the dc value nor the rms of s d 1 , s d 2 and s d 3 voltages. it does not change the dc value of s d 0 voltage, but affects its rms, as explained in table 1. table 1. how to switch one segment on and off in 4-multiplexed drive note that even if a segment is off, its rms voltage is not zero. as a result, contrast is not as good as in direct drive. in addition, there is a risk of cross-talk (or ghosting): if segment voltage ( s d i ) frequency is too high, a segment can become opaque even though the rms voltage is below the threshold. so make sure that the driving frequency (considering the whole cycle, i.e. the 8 phases) is under 2000 hz typically. the intermediate voltage v dd /2 is only required for the backplane voltages. the st62 i/o pins connected to the backplanes are configured by software to output mode for 0 or v dd levels or to high impedance input mode for v dd /2. this intermediate voltage is defined by two equal- valued resistors externally connected to the i/o pin. by using an mcu with flexible i/o pin configuration such as a standard st62, 4-multiplexed lcd drive can be made with only 8 additional resistors. s waveform segment s 0 other segments dc rms state dc rms state h during j 0 , l during j 4 0 ( ? 3/4).v dd off 0 only depend on the rest of s waveform l during j 0 , h during j 4 0 ( ? 7/4).v dd on 0
6/26 4-multiplexed lcd with a standard st62 figure 5. lcd signals for 4-multiplexed mode (used in library) t t t com 0 s t com 1 t com 2 t com 3 j 0 j 1 j 2 j 3 j 4 j 5 j 6 j 7 j 0 j 1 j 2 j 3 j 4 j 5 j 6 j 7 s d 0 t s d 1 t s d 2 t s d 3 = com 0 - s ( s d 0 ) rms = ( ? 3/4). v dd t s 0 off ( s d 1 ) rms = ( ? 3/4). v dd t s 1 off ( s d 2 ) rms = ( ? 3/4). v dd t s 2 off ( s d 3 ) rms = ( ? 3/4). v dd t s 3 off ( s d 0 ) rms = ( ? 3/4). v dd t s 0 off ( s d 2 ) rms = ( ? 3/4). v dd t s 2 off ( s d 1 ) rms = ( ? 7/4). v dd t s 1 on ( s d 3 ) rms = ( ? 7/4). v dd t s 3 on v d d 0 v d d 0 v d d 0 v d d 0 v d d 0 v d d 0 -v d d v d d 0 -v d d v d d 0 -v d d v d d 0 -v d d
7/26 4-multiplexed lcd with a standard st62 2 lcd driving software library this library consists in one mast6 source file, lcd_drv.st6 , and its associated include file, lcd_drv.inc . it is targeted to a certain kind of lcd structure. source code is provided to fa- cilitate customisation to a particular lcd and application. the following section presents some guidelines on how to use and customize the library. the targeted lcd is organized into four classical 7-segment digits, plus four icons (e.g. a colon at the middle), creating four 8-segment digits. each digit uses the four backplane pins and two frontplane pins. figure 6. connections for an 8-segment digit (example with a colon) typically, this kind of lcd is suited to 24-hour clock display. therefore, the digits are called, from left to right: hours digit 1, hours digit 0, minutes digit 1, minutes digit 0. the first part of this section explains how to use the library provided the lcd is wired exactly like the target is, and provided the mcu pin allocations are compatible with the rest of the ap- plication. the second part gives more details on the data operations performed internally by the driver, to be able to customise it if necessary. finally, the third part gives an example of how to manage timing resources to combine lcd requirements with the main tasks of the ap- plication. 2.1 non-customised usage 2.1.1 allocation of i/o resources all the mcu output pins generating the s signals are located in the same i/o port, called seg- ments port. a different i/o port, called commons port is used for the pins generating the com signals. the software driver has no effect on the other i/o pins, even if they are located in one of those ports. com 3 com 2 com 1 com 0 s 3 s 2 am pm c
8/26 4-multiplexed lcd with a standard st62 the code uses dr_seg , ddr_seg and or_seg labels to access the configuration registers of the segments port. dr_com , ddr_com and or_com labels are used for the commons port. dr_seg_2 and dr_com_2 are labels referring to ram variables used as shadow i/o port data registers. these 8 labels are declared as external at the beginning of lcd_drv.st6 . therefore, to make the library work, you must define them as synonyms of actual configura- tion registers, like in the following example: ddr_com data ddrb dr_com data drb or_com data orb ddr_seg data ddra dr_seg data dra or_seg data ora dr_com_2 data drb_2 dr_seg_2 data dra_2 these definitions must be performed in another source file which is to be linked with lcd_drv.st6 . note: in this example, dra_2 and drb_2 definitions must be in the same source file as dr_seg_2 and dr_com_2 definitions, otherwise the data directive does not work. once the segments and commons ports defined, the mcu must be wired according to figure 6. note that a pair of s pins is assigned to each 8-segment digit. to understand the roles of each of the two pins, refer to figure 6.
9/26 4-multiplexed lcd with a standard st62 figure 7. template for mcu C lcd connections 2.1.2 driver subroutines and variables the main application communicates with the lcd driver through six 8-bit variables and 3 sub- routines, all declared in lcd_drv.inc . the six variables are written by the main application and read by the software lcd driver. they describe the information that should be displayed: C hr_dig1 , hr_dig0 , min_dig1 and min_dig0 contain the code of the character to be dis- played on each 7-segment digit; C icons is a byte of flags indicating, for each icon, if it must be on or off; C flashing is a byte of flags indicating, for each 7-segment digit and each icon, if it must be flashing or not. pin 3 pin 2 pin 1 pin 0 commons port v dd st62 pin 3 pin 0 pin 1 pin 2 pin 4 pin 5 pin 6 pin 7 segments port com 3 com 2 com 1 com 0 s 0 s 1 s 2 s 3 s 4 s 5 s 6 s 7 lcd 470k resistors am pm c
10/26 4-multiplexed lcd with a standard st62 the driver supports 16 different characters to be displayed on a digit: the 10 numeric digits, some letters or symbols, or the blank digit. the character coding is included in the library through a look-up table. table 2. character coding for 7-segment digits table 3. bit definitions for icons variable bit 3:0 = ico[3..0] icon on/off these bits indicate, for each icon segment, if it must be on or off. 0: icon segment off 1: icon segment on table 4. bit definitions for flashing variable bit 3:0 = ico[3..0] icon flashing on/off these bits indicate, for each icon segment, if it must be flashing or not. 0: icon segment not flashing 1: icon segment flashing bit 5:4 = min[1..0] minute digit flashing on/off these bits indicate, for each minute 7-segment digit, if it must be flashing or not. 0: digit not flashing 1: digit flashing bit 7:6 = hr[3..0] hour digit flashing on/off these bits indicate, for each hour 7-segment digit, if it must be flashing or not. 0: digit not flashing 1: digit flashing code 0 1 2 3 4 5 6 7 8 9 a b c d e f display 7 0 - - - - ico3 ico2 ico1 ico0 7 0 hr0 hr1 min0 min1 ico3 ico2 ico1 ico0
11/26 4-multiplexed lcd with a standard st62 to use the lcd driver, proceed as follows: C before calling any lcd driver subroutine, the main routine must initialise the six display var- iables. C then, it must call the lcd_init subroutine to initialise lcd driver internal variables and to configure segment port pins as output push-pull. C once the lcd_init subroutine called, the main software must frequently call the lcd_do subroutine. this subroutine updates the i/o ports so as to generate the required waveforms. the delay between two consecutive calls to lcd_do represents the duration of 1 lcd phase, which is 1/8 th of the total lcd cycle (cf. section 1.3). C the six display variables can be modified at any time by the main software. each time the lcd_do subroutine is executed, it reports the changes on the waveforms, i.e. on the lcd. C in parallel to lcd_do calls, the main software must call the lcd_flash subroutine. the de- lay between two consecutive calls to lcd_flash represents half of the flashing period. C it is the main software that is in charge of generating a time base (generally using a timer peripheral). this way, a single time base can be used at the same time for lcd driving, flash- ing frequency and other application tasks. important notice: if delays between calls to lcd_do are too irregular, lcd segment absolute dc voltage can become too high, with a risk of damaging the lcd. 2.2 additional information for customisation the current lcd phase ( j 0 to j 7 ) is stored into lcd_ph , an 8-bit variable internal to the lcd driver. this variable is initialised by lcd_init and incremented by lcd_do , from 0 to 7 and back to 0. to update the configuration register of the segments and commons ports, lcd_do uses lcd_ph as an index to scan look-up tables. note: because computing the new register values takes time, lcd_do stores the new values in ram buffers, and updates all the real registers at the same time. this way, transitions on backplane and frontplane waveforms can be synchronised. this synchronisation helps keeping a low dc voltage on lcd segments. for data registers, the ram buffer used is the shadow register. the algorithms described in this section are designed to generate the proper backplane and frontplane signals as described in section 1.3 . 2.2.1 generation of backplane signals each time lcd_do is executed, it updates the three configuration registers (ddr, dr and or) of the commons port, in order to output either 0, v dd /2 or v dd on the backplane pins. lcd_drv.st6 defines three constant tables giving the values of each configuration register depending on the current lcd phase:
12/26 4-multiplexed lcd with a standard st62 wave_ddr: db 001h,002h,004h,008h,001h,002h,004h,008h wave_dr: db 00fh,00fh,00fh,00fh,00eh,00dh,00bh,007h wave_or: db 001h,002h,004h,008h,001h,002h,004h,008h when applying these values to the port registers, lcd_do uses a mask ( com_mask equate) to modify only the appropriate pins. to modify the data register, it uses dr_com_2 shadow reg- ister. how to customise: it is easy to modify the pins allocation for backplane pins, as long as they all belong to the same i/o port. you only need to change com_mask and the three constant ta- bles. 2.2.2 generation of frontplane signals here, lcd_do only has to update the data register. but operations are more complex be- cause of character coding. the procedure contains four steps: step 1: writing into variables that are images of min_dig0 , min_dig1 , hr_dig0 , hr_dig1 and icons , taking flashing into account : the image variable contains either a blank value or the content of the original variable. this image variable represents what is really to be dis- played on the lcd. for example, if a digit displays a flashing 9, its image variable contains alternately '9' or 'f' (code for blank digit). step 2: updating the data shadow register only considering the 7-segment characters. this requires a constant table to store character coding. step 3: updating the data shadow register taking the icons into account. step 4: copying the data shadow register into the data register. steps 1 and 4 are independent from i/o pins allocation, so they will not be described here. step 2 starts by clearing the data shadow register for all the frontplane pins. then, for each 7-segment digit, the cycle of operations described by figure 8 modifies this shadow register. due to the mask mechanism, the add operation is equivalent to an or (the st6 instruction set does not supply a direct or operation). because all icon segments are located on the first backplane (com 0 ), step 3 is performed only in phases j 0 and j 4 . after step 2, the data shadow register is configured in a way that all icon segments are off. step 3 consists in correcting the shadow register to make sure that all required icons are on. to do this, it performs bit manipulation instructions with the following bit definition equates: icon0_seg equ 1 icon1_seg equ 3 icon2_seg equ 5 icon3_seg equ 7
13/26 4-multiplexed lcd with a standard st62 how to customise: as long as all frontplane pins belong to the same i/o port, it is possible to change i/o pin allocations or character coding just by modifying the equates and constant table definitions located at the beginning of lcd_drv.st6 : C the mask equates selecting all or a subset of the frontplane pins, C the look-up table for character coding, C the bit definition equates selecting frontplane pins related to icon segments. figure 8. operations to convert a character code into a frontplane waveform inversion charac: db 0aah,000h,055h,000h ; display 0 db 0ffh,0aah,0ffh,0aah ; display 1 db 0aah,055h,0aah,000h ; display 2 db 0aah,0aah,0aah,000h ; display 3 db 0ffh,0aah,000h,0aah ; display 4 db 0aah,0aah,000h,055h ; display 5 db 0aah,000h,000h,055h ; display 6 db 0ffh,0aah,0ffh,000h ; display 7 db 0aah,000h,000h,000h ; display 8 db 0aah,0aah,000h,000h ; display 9 db 0ffh,000h,000h,0aah ; display h db 0ffh,0ffh,0aah,0ffh ; display - db 0aah,055h,055h,0aah ; display l db 0ffh,055h,000h,000h ; display p db 0aah,055h,000h,055h ; display e db 0ffh,0ffh,0ffh,0ffh ; display 'blank' min_dig1i = 9 lcd_ph mod 4 = 0 lcd_ph = 4 1 1 1 0 0 0 1 0 0 0 1 0 1 0 0 0 lcd_ph 3 4 1 1 1 0 0 0 1 0 0 0 1 0 0 0 0 0 and 0 0 0 0 0 1 0 0 previous value of dr_seg_2 min_dig1 = 9 step 1 0 0 1 0 0 1 0 0 add new value stored into dr_seg_2 look- up table defined in lcd_drv.st 6 image variable of min_dig1 example with minutes digit 1 ; (bit = 1) <=> pin is a frontplane pin for: min0_sel equ 003h ; - digit 0 for minutes min1_sel equ 00ch ; - digit 1 for minutes hr0_sel equ 030h ; - digit 0 for hours hr1_sel equ 0c0h ; - digit 1 for hours equates defined in lcd_drv.st6
14/26 4-multiplexed lcd with a standard st62 2.3 example of application timing C a simple clock as explained in section 2.1, the main application is in charge of providing the time base to the lcd driver. because this time base must be relatively precise, it is usually generated by a spe- cific sub-system of the application, either internal to the mcu (timer peripheral) or external (e.g. external clock source, rc network, etc.). in both cases, mcu resources are dedicated to it (peripheral if internal, pins if external). this part describes a solution to share a single time base between the lcd driver and the main application. sharing is usually necessary if the st6 device has few resources. the main application is a real time 24-hour clock to be displayed on the lcd. in order to use as few pins as possible, the time base is generated by a standard 8-bit timer clocked by the mcu internal clock. the real time clock requires frequencies far lower than the lcd driver. consequently, the time base runs at the frequency required by the lcd driver. then, this frequency is divided by soft- ware counters to reach a period of 125 ms, then divided again to reach periods of 0.5 second, 1 second, 1 minute and 1 hour. the half-second period is involved in making some lcd seg- ments flash at 1 hz. for example, when the clock is running, the colon flashes at that fre- quency. the standard timer is configured in output mode with interrupts enabled, so that the timer in- terrupt service routine (isr) is called every 1.5 ms. this routine calls the lcd_do routine. as a result, an lcd cycle (8 phases) lasts 1.5*8 = 12 ms, so lcd voltage frequency is 83 hz, which is in the required range. reaching a period of 125 ms requires dividing the timer interrupt frequency by 250/3. to do so, the timer isr decrements a counter (ram variable) three times. after each decrement, it checks if the counter has reached 0 or not. if it has, the isr calls an rtc subroutine. this sub- routine reloads the counter with 250. the rtc subroutine, called once every 1/8 s, performs several frequency divisions to update the second, minute and hour counters. also, it calls lcd_flash once every half second.
15/26 4-multiplexed lcd with a standard st62 3 appendix: source code lcd_drv.inc ; ********************************************************* ;* (c) 2001 stmicroelectronics * ;* project : 8*4 segment lcd software driver * ;* toolchain : st6 toolchain for ride v 1.0.c * ;* target : in theory, any st62 * ;* module : lcd_drv.inc * ;* version : v 0.1.1 - may 2001 * ;* author : t.b. hong kong application * ; ********************************************************* ;* software lcd driver library: * ;* - definitions of the variables * ;* - constant tables * ;* - driver subroutines * ; ********************************************************* ;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* ; *-*-*-*-*- variables and equates *-*-*-*-*-*- ;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* ; character codes extern data (min_dig0) ; digit 0 for minutes extern data (min_dig1) ; digit 1 for minutes extern data (hr_dig0) ; digit 0 for hours extern data (hr_dig1) ; digit 1 for hours ; code : 0 1 2 3 4 5 6 7 8 9 a b c d e f ; display : 0 1 2 3 4 5 6 7 8 9 h - l p e blank equ 0fh dash equ 0bh extern data (icons) ; byte of flags for icons on/off state ; (0 = off, 1 = on) extern data (flashing) ; byte of flags for digits and icons ; flashing state ; (0 = not flashing, 1 = flashing) ; bit definitions for 'icons' and 'flashing' variables ico0 equ 0 ; bit 0: icon 0 ico1 equ 1 ; bit 1: icon 1 ico2 equ 2 ; bit 2: icon 2 ico3 equ 3 ; bit 3: icon 3 min0 equ 4 ; bit 4: digit 0 for minutes min1 equ 5 ; bit 5: digit 1 for minutes hr0 equ 6 ; bit 6: digit 0 for hours hr1 equ 7 ; bit 7: digit 1 for hours
16/26 4-multiplexed lcd with a standard st62 ;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* ; *-*-*-*-*-*-*-* subroutines *-*-*-*-*-*-*-*-* ;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* ;***************************************************************** extern code (lcd_init) ; initialises the ressources used by the library. ; prereq. : none ; inputs : none ; outputs : internal variables initialised, ; segment pins configured as output push-pull ;***************************************************************** ;***************************************************************** extern code (lcd_flash) ; switches the flash strobe if necessary ; prereq. : none ; inputs : flashing ; outputs : none ;***************************************************************** ;***************************************************************** extern code (lcd_do) ; updates the lcd outputs (commons & segments) to ; display the requested digits. ; prereq. : 'lcd_init' called before ; inputs : 'min_dig0', 'min_dig1', 'hr_dig0', 'hr_dig1' ;+ 'icons' ; outputs : 'ddr_com', 'dr_com', 'dr_com_2', 'or_com', ; 'dr_seg' and 'dr_seg_2' refreshed ; important: once the lcd i/os are initialised, this ; subroutine must be called frequently to prevent ; damaging the lcd. ;***************************************************************** ;******************* (c) 2001 stmicroelectronics *****************
17/26 4-multiplexed lcd with a standard st62 lcd_drv.st6 ; ********************************************************* ;* (c) 2001 stmicroelectronics * ;* project : 8*4 segment lcd software driver * ;* toolchain : st6 toolchain for ride v 1.0.c * ;* target : in theory, any st62 * ;* module : lcd_drv.st6 * ;* version : v 0.1.2 - june 2001 * ;* author : t.b. hong kong application * ; ********************************************************* ;* software lcd driver library: * ;* - public and local variables * ;* - constant tables * ;* - driver subroutines * ; ********************************************************* $include (lcd_drv.inc) ; software lcd driver ;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* ; *-*-*-*-*- i/o configuration equates *-*-*-*- ;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* ; --- port allocation --- extern data (ddr_com, dr_com, or_com) ; lcd commons extern data (ddr_seg, dr_seg, or_seg) ; lcd segments extern data (dr_com_2, dr_seg_2) ; lcd shadow registers ; --- pin allocation --- com_mask equ 0f0h seg_mask equ 000h seg_sel equ 0ffh min0_sel equ 003h min1_sel equ 00ch hr0_sel equ 030h hr1_sel equ 0c0h icon0_seg equ 1 icon1_seg equ 3 icon2_seg equ 5 icon3_seg equ 7
18/26 4-multiplexed lcd with a standard st62 ;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* ; *-*-*-*-*-*-*-*- variables *-*-*-*-*-*-*-*-*- ;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* lcd_vars segment data rseg lcd_vars ;--- public variables --- public min_dig0, min_dig1, hr_dig0, hr_dig1 public icons, flashing ; character codes min_dig0: ds 1 ; digit 0 for minutes min_dig1: ds 1 ; digit 1 for minutes hr_dig0: ds 1 ; digit 0 for hours hr_dig1: ds 1 ; digit 1 for hours ; code : 0 1 2 3 4 5 6 7 8 9 a b c d e f ; display : 0 1 2 3 4 5 6 7 8 9 h - l p e icons: ds 1 ; byte of flags for icons on/off state ; (0 = off, 1 = on) flashing: ds 1 ; byte of flags for digits and icons ; flashing state ; (0 = not flashing, 1 = flashing) ;--- local variables --- lcd_ph: ds 1 ; lcd phase (0 to 7) ddr_com2: ds 1 or_com2: ds 1 strobe: ds 1 ; flash strobe (000h <--> 0ffh) mindig0i: ds 1 ; digit 0 for minutes - image mindig1i: ds 1 ; digit 1 for minutes - image hrdig0i: ds 1 ; digit 0 for hours - image hrdig1i: ds 1 ; digit 1 for hours - image iconsi: ds 1 ; icons - image
19/26 4-multiplexed lcd with a standard st62 ;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* ; *-*-*-*-*-*-* constant tables *-*-*-*-*-*-*-* ;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* ; table of common i/os configuration for commons waveform com_table segment code inwindow rseg com_table ; phase | 0 1 2 3 4 5 6 7 ;----------------------------------------------------------------------- ; com0 | vdd vdd/2 vdd/2 vdd/2 0 vdd/2 vdd/2 vdd/2 ; com1 | vdd/2 vdd vdd/2 vdd/2 vdd/2 0 vdd/2 vdd/2 ; com2 | vdd/2 vdd/2 vdd vdd/2 vdd/2 vdd/2 0 vdd/2 ; com3 | vdd/2 vdd/2 vdd/2 vdd vdd/2 vdd/2 vdd/2 0 wave_ddr: db 001h,002h,004h,008h,001h,002h,004h,008h wave_dr: db 00fh,00fh,00fh,00fh,00eh,00dh,00bh,007h wave_or: db 001h,002h,004h,008h,001h,002h,004h,008h ; table of segment outputs to display a specific character seg_table segment code inwindow rseg seg_table charac: db 0aah,000h,055h,000h ; display 0 db 0ffh,0aah,0ffh,0aah ; display 1 db 0aah,055h,0aah,000h ; display 2 db 0aah,0aah,0aah,000h ; display 3 db 0ffh,0aah,000h,0aah ; display 4 db 0aah,0aah,000h,055h ; display 5 db 0aah,000h,000h,055h ; display 6 db 0ffh,0aah,0ffh,000h ; display 7 db 0aah,000h,000h,000h ; display 8 db 0aah,0aah,000h,000h ; display 9 db 0ffh,000h,000h,0aah ; display h db 0ffh,0ffh,0aah,0ffh ; display - db 0aah,055h,055h,0aah ; display l db 0ffh,055h,000h,000h ; display p db 0aah,055h,000h,055h ; display e db 0ffh,0ffh,0ffh,0ffh ; display 'blank'
20/26 4-multiplexed lcd with a standard st62 ;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* ; *-*-*-*-*-*-*-* subroutines *-*-*-*-*-*-*-*-* ;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* public lcd_init, lcd_flash, lcd_do lcd_subs segment code rseg lcd_subs ;***************************************************************** lcd_init: ; initialises the ressources used by the library. ; prereq. : display variables must have been initialised ; by the main routine ; inputs : none ; outputs : internal variables initialised, ; segment pins configured as output push-pull ;***************************************************************** clr lcd_ph clr strobe ldi a,seg_sel add a,ddr_seg ld ddr_seg,a ldi a,seg_sel add a,or_seg ld or_seg,a ; output internal to the driver: ; 'lcd_ph' and 'strobe' initialised' ret ;***************************************************************** lcd_flash: ; switches the flash strobe if necessary ; prereq. : none ; inputs : 'flashing' ; outputs : none ;***************************************************************** ld a,strobe jrnz strobe1 strobe0: ld a,flashing jrz exit_sub ldi strobe,0ffh exit_sub: ret strobe1: clr strobe ret
21/26 4-multiplexed lcd with a standard st62 ;***************************************************************** lcd_do: ; updates the lcd outputs (commons & segments) to ; display the requested digits. ; prereq. : 'lcd_init' called before ; inputs : 'min_dig0', 'min_dig1', 'hr_dig0', 'hr_dig1' ; + 'icons' ; outputs : 'ddr_com', 'dr_com', 'dr_com_2', 'or_com', ; 'dr_seg' and 'dr_seg_2' refreshed ; important: once the lcd i/os are initialised, this ; subroutine must be called frequently to prevent ; damaging the lcd. ;***************************************************************** ;--- depending on flash strobe, update segment images --- ld a,min_dig0 jrr 0,strobe,min0 jrr min0,flashing,min0 ldi a,blank min0: ld mindig0i,a ld a,min_dig1 jrr 0,strobe,min1 jrr min1,flashing,min1 ldi a,blank min1: ld mindig1i,a ld a,hr_dig0 jrr 0,strobe,hr0 jrr hr0,flashing,hr0 ldi a,blank hr0: ld hrdig0i,a ld a,hr_dig1 jrr 0,strobe,hr1 jrr hr1,flashing,hr1 ldi a,blank hr1: ld hrdig1i,a clr a jrr 0,strobe,iconsegs ld a,flashing iconsegs: com a and a,icons ld iconsi,a
22/26 4-multiplexed lcd with a standard st62 ;--- update segments outputs (shadow register) --- seg_upd: ld a,dr_seg_2 andi a,seg_mask ld dr_seg_2,a ld a,lcd_ph andi a,03h ld v,a ; v = lcd_ph mod 4 ; -- numeric digits -- ; digit 0 for minutes ld a,mindig0i ldi w,min0_sel call find_seg ; digit 1 for minutes ld a,mindig1i ldi w,min1_sel call find_seg ; digit 0 for hours ld a,hrdig0i ldi w,hr0_sel call find_seg ; digit 1 for hours ld a,hrdig1i ldi w,hr1_sel call find_seg ; -- icons -- ld a,v jrz do_icon0 ; all icon segments are on com0 jp com_upd ; icon 0 segment do_icon0: jrr ico0,iconsi,do_icon1 jrs 2,lcd_ph,icon0_1 icon0_0: res icon0_seg,dr_seg_2 jp do_icon1 icon0_1: set icon0_seg,dr_seg_2
23/26 4-multiplexed lcd with a standard st62 ; icon 1 segment do_icon1: jrr ico1,iconsi,do_icon2 jrs 2,lcd_ph,icon1_1 icon1_0: res icon1_seg,dr_seg_2 jp do_icon2 icon1_1: set icon1_seg,dr_seg_2 ; icon 2 segment do_icon2: jrr ico2,iconsi,do_icon3 jrs 2,lcd_ph,icon2_1 icon2_0: res icon2_seg,dr_seg_2 jp do_icon3 icon2_1: set icon2_seg,dr_seg_2 ; icon 3 segment do_icon3: jrr ico3,iconsi,com_upd jrs 2,lcd_ph,icon3_1 icon3_0: res icon3_seg,dr_seg_2 jp com_upd icon3_1: set icon3_seg,dr_seg_2 ;--- update commons i/os (shadow registers) --- com_upd: ldi dwr,#window(wave_ddr) ; update ddr ldi a,#winoffset(wave_ddr) add a,lcd_ph ld x,a ld a,ddr_com andi a,com_mask add a,(x) ld ddr_com2,a ; update dr and dr_2 ldi a,#winoffset(wave_dr) add a,lcd_ph ld x,a ld a,dr_com_2 andi a,com_mask add a,(x) ld dr_com_2,a ; update or ldi a,#winoffset(wave_or)
24/26 4-multiplexed lcd with a standard st62 add a,lcd_ph ld x,a ld a,or_com andi a,com_mask add a,(x) ld or_com2,a ;--- perform the changes on the real ports --- ; segments port ld a,dr_seg_2 ld dr_seg,a ; commons port ld a,or_com andi a,com_mask ld or_com,a ld a,ddr_com2 ld ddr_com,a ld a,dr_com_2 ld dr_com,a ld a,or_com2 ld or_com,a ;--- increment phase counter --- inc lcd_ph ld a,lcd_ph andi a,07h ld lcd_ph,a ; lcd_ph = (lcd_ph + 1) mod 8 ; output internal to the driver: ; 'lcd_ph' updated ret ;***************************************************************** find_seg: ; finds the segment outputs for a given digit, a given ; character and a given lcd phase. ; prereq. : none ; inputs : 'lcd_ph', v = lcd_ph mod 4, ; a = code of the character (0 to 15), ; w = segment i/o port mask for the digit ; outputs : 'dr_seg_2' refreshed ; modifies : x ;*****************************************************************
25/26 4-multiplexed lcd with a standard st62 sla a sla a ; * 4 ldi dwr,#window(charac) addi a,#winoffset(charac) add a,v ld x,a ld a,(x) jrr 2,lcd_ph, dr_chg ; if lcd_ph >= 4, com a ; invert outputs dr_chg: and a,w add a,dr_seg_2 ld dr_seg_2,a ret end ;******************* (c) 2001 stmicroelectronics *****************
26/26 4-multiplexed lcd with a standard st62 "the present note which is for guidance only aims at providing cus- tomers with information regarding their products in order for them to save time. as a result, stmicroelectronics shall not be held liable for any direct, indirect or consequential damages with respect to any claims arising from the content of such a note and/or the use made by customers of the information contained herein in connexion with their products." information furnished is believed to be accurate and reliable. however, stmicroelectronics assumes no responsibility for the co nsequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. no license is granted by implication or otherwise under any patent or patent rights of stmicroelectronics. specifications mentioned in this publicati on are subject to change without notice. this publication supersedes and replaces all information previously supplied. stmicroelectronics prod ucts are not authorized for use as critical components in life support devices or systems without the express written approval of stmicroele ctronics. the st logo is a registered trademark of stmicroelectronics ? 2001 stmicroelectronics - all rights reserved. purchase of i 2 c components by stmicroelectronics conveys a license under the philips i 2 c patent. rights to use these components in an i 2 c system is granted provided that the system conforms to the i 2 c standard specification as defined by philips. stmicroelectronics group of companies australia - brazil - china - finland - france - germany - hong kong - india - italy - japan - malaysia - malta - morocco - sin gapore - spain sweden - switzerland - united kingdom - u.s.a. http://www.st.com


▲Up To Search▲   

 
Price & Availability of AN1447

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X